import request from '@/utils/request.js'
// 获取文章详情
export const getArticleInfoAPI = function (id) {
  return request.get('/v1_0/articles/' + id)
}

// 关注文章作者API接口
// target 是文章 作者的id
export const followUserAPI = function (target) {
  return request.post('/v1_0/user/followings', { target })
}

// 取关作者
// id 是文章 作者的id
export const unfollowUserAPI = function (id) {
  return request.delete('/v1_0/user/followings/' + id)
}

// 点赞作者
// target 是文章的id
export const likeArticleAPI = function (target) {
  return request.post('/v1_0/article/likings', { target })
}

// 取消点赞
// id 是文章的id
export const dislikeArticleAPI = function (id) {
  return request.delete('/v1_0/article/likings/' + id)
}

// 根据文章 id 请求文章下评论的接口
export const getCmtListAPI = function (source, offset) {
  return request.get('/v1_0/comments', {
    params: {
      type: 'a',
      // 文章的id
      source,
      // 偏移量,用来实现分页的
      offset
    }
  })
}

// 评论点赞
// target 评论的 id
export const getCommentAPI = function (target) {
  return request.post('/v1_0/comment/likings', { target })
}

// 取消评论点赞
// id 是评论的id
export const unGetCommentAPI = function (id) {
  return request.delete('/v1_0/comment/likings/' + id)
}

// 发表评论
// target 文章的ID ,content 评论的内容
export const publishCommentAPI = function (target, content) {
  return request.post('/v1_0/comments', { target, content })
}
